<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
    <style type="text/css">
        html,
        body {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }

        #map_container {
            width: 100%;
            height: 100%;
            margin: 0;
        }
    </style>
    <script type="text/javascript"
            src="https://api.map.baidu.com/api?type=webgl&v=1.0&ak=G1LFyjrNGIkns5OfpZnrCGAKxpycPLwb"></script>
    <script src="https://mapv.baidu.com/gl/examples/static/common.js"></script>
    <script src="https://mapv.baidu.com/build/mapv.js"></script>
    <script src="https://code.bdstatic.com/npm/mapvgl@1.0.0-beta.54/dist/mapvgl.min.js"></script>
    <script src="https://code.bdstatic.com/npm/mapvgl@1.0.0-beta.54/dist/mapvgl.threelayers.min.js"></script>
    <title>地图展示</title>
</head>
<body>
<div id="map_container"></div>
<script type="text/javascript">
    var map = initMap({
        tilt: 0,
        center: [108.154518, 36.643346],
        zoom: 5,
        style: darkStyle
    })
    setData(initData());

    function initData() {
        var data = [];
        var citys = [
            '北京', '天津', '上海', '重庆', '石家庄', '太原', '呼和浩特', '哈尔滨', '长春',
            '沈阳', '济南', '南京', '合肥', '杭州', '南昌', '福州', '郑州', '武汉', '长沙', '广州',
            '南宁', '西安', '银川', '兰州', '西宁', '乌鲁木齐', '成都', '贵阳', '昆明', '拉萨', '海口'
        ];
        // 目标城市
        var targetCity = mapv.utilCityCenter.getCenterByCityName('北京');

        var curve = new mapvgl.BezierCurve();
        for (let i = 1; i < citys.length; i++) {
            var startCity = mapv.utilCityCenter.getCenterByCityName(citys[i]);
            curve.setOptions({
                start: [startCity.lng, startCity.lat],
                end: [targetCity.lng, targetCity.lat]
            })
            // 坐标
            var curveModelData = curve.getPoints();
            data.push({
                geometry: {
                    type: 'LineString',
                    coordinates: curveModelData
                }
            });
        }
        return data;
    }

    function setData(data) {
        var view = new mapvgl.View({
            map: map
        });

        var lineLayer = new mapvgl.LineLayer({
            color: 'rgba(33, 242, 214, 0.3)', //线的颜色
            blend: 'lighter'
        });
        view.addLayer(lineLayer);
        lineLayer.setData(data);

        var linePointLayer = new mapvgl.LinePointLayer({
            size: 8, // 点的大小
            speed: 10, // 点的运用速度
            color: 'rgba(255, 255, 0, 0.6)', // 点的颜色
            animationType: mapvgl.LinePointLayer.ANIMATION_TYPE_SMOOTH, // 点的动画
            shapeType: mapvgl.LinePointLayer.SHAPE_TYPE_CIRCLE, // 点的形状
            blend: 'lighter'
        })
        view.addLayer(linePointLayer)
        linePointLayer.setData(data)
    }
</script>
</body>
</html>